﻿<Window
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"      
    xmlns:local="clr-namespace:CinchCodeGen"
	x:Class="CinchCodeGen.MainWindow"
	x:Name="win"
	Title="Cinch MVVM Code Generator"
    Icon="Images/CodeGen.ico"
    Background="{x:Null}" 
    Topmost="False" 
    WindowStartupLocation="CenterScreen" 
    WindowState="Maximized"
    MinHeight="575" 
    MinWidth="1000"
    WindowStyle="None" 
    Template="{StaticResource WindowTemplateKey}"
    TextElement.Foreground="White"
    ResizeMode="CanResizeWithGrip" AllowsTransparency="True">

    <Window.Resources>

        <local:BoolToVisibilityConverter x:Key="VisibleIfTrueConv" Inverted="True" Not="False" />
        <local:BoolToVisibilityConverter x:Key="ValidToVisibleConv" Inverted="True" Not="False" />
        <local:BoolToVisibilityConverter x:Key="ValidToInVisibleConv" Inverted="True" Not="True" />
        <local:EnumToBooleanConverter x:Key="enumBooleanConv" />

        <!-- PropertiesViewModel -->
        <DataTemplate DataType="{x:Type local:PropertiesViewModel}">
            <AdornerDecorator>
                <local:PropertiesView />
            </AdornerDecorator>
        </DataTemplate>

        <DataTemplate DataType="{x:Type local:GeneratedCodeViewModel}">
            <local:GeneratedCodeView />
        </DataTemplate>



    </Window.Resources>

        <Grid Background="Transparent">

        <Border CornerRadius="10,10,10,10" Background="White"
            BorderBrush="Black" BorderThickness="8">

            <Grid Background="#ff656565">

                <Grid.RowDefinitions>
                    <RowDefinition Height="50"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <!-- top area-->
                <Grid Grid.Row="0" HorizontalAlignment="Stretch" Height="50" Margin="0,0,0,0"
                  MouseLeftButtonDown="Rectangle_MouseLeftButtonDown"
                  Background="Black" >
                    <Image Source="Images/header.png" Width="500" Height="50" Margin="10,5,5,5" 
                           HorizontalAlignment="Left" VerticalAlignment="Center"/>
                </Grid>

                <StackPanel Grid.Row="1" Orientation="Horizontal" 
                            HorizontalAlignment="Left" Margin="10"
                            Background="Transparent">
                    <Button Tag="../Images/New.png"  Command="{Binding NewVMCommand}"
                            Style="{StaticResource imageButtons}" Width="40" Height="40"  
                            ToolTip="New ViewModel" />
                    <Button Tag="../Images/open.png"  Command="{Binding OpenVMCommand}" 
                            Style="{StaticResource imageButtons}" Width="40" Height="40"   
                            ToolTip="Open Existing ViewModel" />
                    <Button Tag="../Images/save.png"  Command="{Binding CurrentVM.SaveVMCommand}" 
                            Style="{StaticResource imageButtons}" Width="40" Height="40"   
                            ToolTip="Save Current ViewModel"/>
                    <Button Tag="../Images/gen1.png"  Command="{Binding CurrentVM.GenerateVMCommand}" 
                            Style="{StaticResource imageButtons}" Width="40" Height="40"   
                            ToolTip="Generate ViewModel Code"/>
                 </StackPanel>




                <!-- bottom area-->
                <Grid Grid.Row="2" 
                      Visibility="{Binding HasContent, Converter={StaticResource VisibleIfTrueConv}}"
                      HorizontalAlignment="Stretch" 
                      VerticalAlignment="Stretch">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="280"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>


                    <!-- Column 0 -->
                    <Grid Grid.Column="0" HorizontalAlignment="Stretch" 
                            VerticalAlignment="Stretch">


                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>

                        <Image Grid.Row="0" Source="Images/Valid.png" Width="160" 
                                Visibility="{Binding IsValid, 
                                    Converter={StaticResource ValidToVisibleConv}}"
                               Height="160" HorizontalAlignment="Center"
                               VerticalAlignment="Top" Margin="10,10,0,0"/>

                        <Image Grid.Row="0" Source="Images/InValid.png" Width="160" 
                                Visibility="{Binding IsValid, 
                                    Converter={StaticResource ValidToInVisibleConv}}"
                               Height="160" HorizontalAlignment="Center"
                               VerticalAlignment="Top" Margin="10,10,0,0"/>


                        <Border Grid.Row="1" Background="Transparent" 
                                VerticalAlignment="Top"
                                HorizontalAlignment="Stretch"
                                Margin="10,0,0,0">
                            <StackPanel Orientation="Vertical">
                                <Label FontFamily="Arial" FontSize="13" 
                                   Content="Give It A Name" Margin="5"
                                   VerticalAlignment="Top"  Foreground="Black"
                                   FontStyle="Italic" FontWeight="Bold"
                                   HorizontalAlignment="Left"/>
                                <TextBox Margin="5,0,5,0" VerticalAlignment="Top"
                                    Text="{Binding Path=CurrentVM.ViewModelName,
                                    UpdateSourceTrigger=LostFocus, ValidatesOnDataErrors=True,
                                    ValidatesOnExceptions=True}"/>
                                <Label FontFamily="Arial" FontSize="13" 
                                   Content="What's it's namespace" Margin="5"
                                   VerticalAlignment="Top"  Foreground="Black"
                                   FontStyle="Italic" FontWeight="Bold"
                                   HorizontalAlignment="Left"/>
                                <TextBox Margin="5,0,5,0" VerticalAlignment="Top"
                                    Text="{Binding Path=CurrentVM.ViewModelNamespace,
                                    UpdateSourceTrigger=LostFocus, ValidatesOnDataErrors=True,
                                    ValidatesOnExceptions=True}"/>
                            </StackPanel>
                            
                        </Border>

                        <Border Grid.Row="2" Background="Transparent" 
                                HorizontalAlignment="Stretch"
                                Margin="10,20,0,0">
                            <StackPanel Orientation="Vertical">
                                <Label FontFamily="Arial" FontSize="13" 
                                   Content="Pick The Type" Margin="5"
                                   VerticalAlignment="Top" Foreground="Black"
                                   FontStyle="Italic" FontWeight="Bold"
                                   HorizontalAlignment="Left"/>
                                <RadioButton Content="Standard" GroupName="VmOpt"
                                   Margin="5,2,5,2" VerticalAlignment="Top"
                                   IsChecked="{Binding Path=CurrentVM.CurrentViewModelType, 
                                        Converter={StaticResource enumBooleanConv}, 
                                        ConverterParameter=Standard}"/>
                                <RadioButton Content="Validating" GroupName="VmOpt"
                                   Margin="5,2,5,2" VerticalAlignment="Top"
                                   IsChecked="{Binding Path=CurrentVM.CurrentViewModelType, 
                                        Converter={StaticResource enumBooleanConv}, 
                                        ConverterParameter=Validating}"/>
                                <RadioButton Content="Validating And Editable" GroupName="VmOpt"
                                   Margin="5,2,5,2" VerticalAlignment="Top"
                                   IsChecked="{Binding Path=CurrentVM.CurrentViewModelType, 
                                        Converter={StaticResource enumBooleanConv}, 
                                        ConverterParameter=ValidatingAndEditable}"/>
                            </StackPanel>

                        </Border>

                


                    </Grid>
                    
                    <!-- Column 1 -->
                    <Border Margin="10,10,20,20" Grid.Column="1" BorderBrush="Black"
                            BorderThickness="2" Background="Black" 
                            CornerRadius="5">

                        <local:TabControlEx Style="{StaticResource tab}" 
                                Background="Transparent" Foreground="Black"
                                IsSynchronizedWithCurrentItem="True" 
                                ItemsSource="{Binding Path=CurrentVM.Workspaces}" />
                    </Border>
                            



                </Grid>



            </Grid>

        </Border>

        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,10,0,0"
                                    VerticalAlignment="Top" Height="Auto" Width="291.741"  >

            <Button x:Name="btnSize" FontFamily="Webdings" Content="1" 
                    RenderTransformOrigin="0.5,0.5"
                    Style="{StaticResource mainWinButtons}" 
                    ToolTip="Manually Size" Click="btnSize_Click">
                <Button.LayoutTransform>
                    <TransformGroup>
                        <ScaleTransform ScaleX="1" ScaleY="1"/>
                        <SkewTransform AngleX="0" AngleY="0"/>
                        <RotateTransform Angle="-15.826"/>
                        <TranslateTransform X="0" Y="0"/>
                    </TransformGroup>
                </Button.LayoutTransform>
            </Button>
            <Button x:Name="btnMin" FontFamily="Wingdings 3" Content="q" 
                    RenderTransformOrigin="0.5,0.5" Margin="0,20,0,0"
                    Style="{StaticResource mainWinButtons}" 
                    ToolTip="Minimize" Click="btnMin_Click" >
                <Button.RenderTransform>
                    <TransformGroup>
                        <ScaleTransform ScaleX="1" ScaleY="1"/>
                        <SkewTransform AngleX="0" AngleY="0"/>
                        <RotateTransform Angle="16.771"/>
                        <TranslateTransform X="0" Y="0"/>
                    </TransformGroup>
                </Button.RenderTransform>
            </Button>
            <Button x:Name="btnMax" FontFamily="Wingdings 3" Content="p" 
                    RenderTransformOrigin="0.5,0.5" Margin="-5,0,0,0"
                    Style="{StaticResource mainWinButtons}" 
                    ToolTip="Maximize" Click="btnMax_Click" >
                <Button.RenderTransform>
                    <TransformGroup>
                        <ScaleTransform ScaleX="1" ScaleY="1"/>
                        <SkewTransform AngleX="0" AngleY="0"/>
                        <RotateTransform Angle="-25.349"/>
                        <TranslateTransform X="0" Y="0"/>
                    </TransformGroup>
                </Button.RenderTransform>
            </Button>
            <Button x:Name="btnClose" FontFamily="Wingdings" Content="û" 
                    RenderTransformOrigin="0.5,0.5" Margin="35,0,0,0"
                    Style="{StaticResource mainWinButtons}" 
                    ToolTip="Close" Click="btnClose_Click">
                <Button.RenderTransform>
                    <TransformGroup>
                        <ScaleTransform ScaleX="1" ScaleY="1"/>
                        <SkewTransform AngleX="0" AngleY="0"/>
                        <RotateTransform Angle="-13.184"/>
                        <TranslateTransform X="0" Y="0"/>
                    </TransformGroup>
                </Button.RenderTransform>
            </Button>
        </StackPanel>

    </Grid>


</Window>